<template>
  <view >
	  <cu-custom bgColor="bg-gradual-blue" :isBack="true">
	  	<block slot="backText">返回</block>
	  
	  </cu-custom>
	   <view class="container">
	
    <!-- 标题 -->
    <view class="title">医生信息</view>

    <!-- 表单 -->
    <uni-forms ref="form"  :rules="rules" @submit="submitForm">
      
      <!-- 姓名 -->
      <uni-forms-item label="姓名" name="name">
        <uni-easyinput v-model="formData.name" placeholder="请输入姓名"></uni-easyinput>
      </uni-forms-item>

      <!-- 身份证号 -->
      <uni-forms-item label="身份证号" name="identityCard">
        <uni-easyinput v-model="formData.identityCard" placeholder="请输入身份证号" type="idcard"></uni-easyinput>
      </uni-forms-item>

      <!-- 提交按钮 -->
      <view class="button-group">
        <uni-button type="primary" @click="submitForm">提交</uni-button>
		{{formData}}
      </view>
      
    </uni-forms>
	 </view>
  </view>
</template>

<script>


export default {
  data() {
    return {
		formErrors:{},
      formData: {
        name: '',
        identityCard: '',
      }}
	  },
 
  methods: {
 submitForm() {
	 
uni.request({
    url: 'http://202.127.200.31:30010/api/user/users', // 请求的URL
    method: 'POST',
    data: this.formData, // 发送的数据
    header: {
        'Content-Type': 'application/json' // 设置请求头为JSON格式
    },
    success: (res) => {
        console.log('提交成功:', res.data);
        this.formErrors = {}; // 清空错误信息
    },
    fail: (err) => {
        console.error('提交失败:', err);
    }
});
   
 }
 }
 }
</script>

<style scoped>
.container {
  padding: 20px;
  background-color: #f5f5f5;
}

.title {
  font-size: 24px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 20px;
}

.uni-forms-item {
  margin-bottom: 10px;
}

.button-group {
  text-align: center;
  margin-top: 20px;
}
</style>